package com.tj.api.rest.account.requset;

import com.fqgj.common.utils.StringUtils;
import com.fqgj.exception.common.ApplicationException;

import java.math.BigDecimal;

/**
 * Created with IntelliJ IDEA.
 * User: anonymous
 * Date: 2020/06/11
 * Time: 下午2:16
 */
public class WithdrawRequest {
    private String withdrawAmount;
    private String mobile;

    public BigDecimal getWithdrawAmount() {
        return new BigDecimal(withdrawAmount);
    }

    public void setWithdrawAmount(String withdrawAmount) {
        this.withdrawAmount = withdrawAmount;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public void verify() {
        if (withdrawAmount == null || new BigDecimal(withdrawAmount).compareTo(BigDecimal.ZERO) < 0) {
            throw new ApplicationException("The amount is incorrect");
        }
        if (StringUtils.isEmpty(mobile)) {
            throw new ApplicationException("Please input mobile");
        }
        if (mobile.length() > 11) {
            throw new ApplicationException("The mobile is incorrect");
        }
    }
}